# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=gnome-software
pkgver=3.36.1
pkgrel=2
pkgdesc="Software lets you install and update applications and system extensions"
url="https://wiki.gnome.org/Apps/Software"
arch="all !s390x !mips !mips64"
license="GPL-2.0-or-later"
makedepends="meson appstream-glib-dev gdk-pixbuf-dev libxmlb-dev glib-dev gtk+3.0-dev
	json-glib-dev libsoup-dev gnome-desktop-dev gspell-dev polkit-dev gtk-doc
	ostree-dev flatpak-dev libgudev-dev gnome-online-accounts-dev"
options="!check" # lots of failing tests
subpackages="$pkgname-lang $pkgname-doc $pkgname-dbg $pkgname-static
	$pkgname-dev $pkgname-plugin-flatpak:flatpak_plugin"
source="https://download.gnome.org/sources/gnome-software/${pkgver%.*}/gnome-software-$pkgver.tar.xz
	445.patch
	install-more-headers.patch
	"

case "$CARCH" in
	x86*) makedepends="$makedepends fwupd-dev" ;;
esac

build() {
	case "$CARCH" in
		x86*) conf="-Dfwupd=true" ;;
		*) conf="-Dfwupd=false" ;;
	esac


	meson \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--buildtype=plain \
		-Dvalgrind=false \
		-Dmalcontent=false \
		-Dpackagekit=false \
		$conf \
		. output
	ninja -C output
}

check() {
	ninja -C output test
}

package() {
	DESTDIR="$pkgdir" ninja -C output install
}

flatpak_plugin() {
	pkgdesc="$pkgdesc (flatpak plugin)"
	install_if="$pkgname=$pkgver-r$pkgrel flatpak"
	depends=""

	amove usr/lib/gs-plugins-13/libgs_plugin_flatpak.so
	amove usr/share/metainfo/org.gnome.Software.Plugin.Flatpak.metainfo.xml
}

sha512sums="7d0e8c16192bbbc8f166db137dbd2e6ff9e85f7d3d37f63f41211ba3838e392bd87a8d9bf09d31b43f6d21e1a099ecdeff9114ae27fae40d563671f0bcbe50d4  gnome-software-3.36.1.tar.xz
2a8746ac0f948022b10fd29bcaf159d428954061d5ae19db86a09733f69901eda61e109ed4b3d3d484d91c182b2967e4b3bc11ce78774885bb9105a752c55c35  445.patch
e7de617dbdecaa46fad25d8fe7d7ea5db324aaed73555bbe6814357b4ac3b787269653863679cff4318250dcc7729299b549f41220f441d9033a448af28da9dd  install-more-headers.patch"
